from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get('http://192.168.20.244/ecshop/admin/privilege.php?act=login')
driver.maximize_window()

# driver.find_element(By.NAME,'username').send_keys('caichang')
# driver.find_element(By.NAME,'password').send_keys('caichang1')
# driver.find_element(By.CLASS_NAME,'btn-a').click()

# ID = "id"
# XPATH = "xpath"
# LINK_TEXT = "link text"
# PARTIAL_LINK_TEXT = "partial link text"
# NAME = "name"
# TAG_NAME = "tag name"
# CLASS_NAME = "class name"
# CSS_SELECTOR = "css selector"

# id是最好用，最有效的定位，正常的都会在元素上定义id属性
# driver.find_element(By.NAME,'username').send_keys('caichang')
# driver.find_element(By.NAME,'password').send_keys('caichang1')
# driver.find_element(By.ID,'tijiao').click()

# name,如上不在解释，优先级仅次于id

# XPATH是第三优先级
# 1、xpath是你需要学的，有一定的学习曲线
# 2、可以通过右键---复制---xpath拿到如下的xpath路径
#    你面试时，也可以这样说
# driver.find_element(By.XPATH,'//*[@id="loginPanel"]/div[1]/input').send_keys('caichang')

# 3、有时候这样得不到的，我们还是要手写xpath
# 4、请下来后，多学习xpath
# driver.find_element(By.XPATH, '//input[@placeholder="请填写您注册的邮箱或手机"]').send_keys('caichang')


# TAG_NAME、CLASS_NAME、CSS_SELECTOR几乎不用，是因为他们无法唯一定位
# driver.find_element(By.TAG_NAME,'input').send_keys('caichang')
# driver.find_element(By.TAG_NAME,'input').send_keys('caichang1')

# LINK_TEXT和PARTIAL_LINK_TEXT是专门为超链接设计,几乎全部用LINK_TEXT
# driver.find_element(By.LINK_TEXT,'忘记密码?').click()
driver.find_element(By.PARTIAL_LINK_TEXT, '记密').click()
